package mfuny.ggongal.admin;

import javax.servlet.http.HttpSession;

import mfuny.ggongal.admin.ad.AdDao;
import mfuny.ggongal.admin.ad.AdTimeService;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class AdTimeController {
	AdTimeService time;
	
	AdDao times;
	
	AdTimeController() throws Exception {
		time = new AdTimeService();
		times = new AdDao();
	}
	
	@RequestMapping("/timeEvent.ga")
	public ModelAndView timeEvent() throws Exception {
		return time.timeEvent( );
	}
	
	@RequestMapping("/regTimeEvent0.ga")
	public ModelAndView regTimeEvent0( HttpSession session ) throws Exception {
		session.removeAttribute( "timeEvent" );
		return time.regTimeEvent0( );
	}
	
	@RequestMapping("/regTimeEvent1.ga")
	public ModelAndView regTimeEvent1(@ModelAttribute AdDao adDao, HttpSession session ) throws Exception {
		session.setAttribute( "timeEvent", adDao );
		return time.regTimeEvent1( );
	}
	
	@RequestMapping("/regTimeEvent2.ga")
	public ModelAndView regTimeEvent2(@ModelAttribute AdDao adDao, HttpSession session ) throws Exception {
		times = (AdDao)session.getAttribute( "timeEvent" );
		times.setT_age( adDao.getT_age( ) );
		times.setT_area( adDao.getT_area( ) );
		times.setT_job( adDao.getT_job( ) );
		times.setT_sex( adDao.getT_sex( ) );
		times.setT_marry( adDao.getT_marry( ) );
		session.setAttribute( "timeEvent", times );
		return time.regTimeEvent2( );
	}
	
	@RequestMapping("/regTimeEvent3.ga")
	public ModelAndView regTimeEvent3(@ModelAttribute AdDao adDao, HttpSession session ) throws Exception {
		times = (AdDao)session.getAttribute( "timeEvent" );
		times.setGame_no( adDao.getGame_no( ) );
		session.setAttribute( "timeEvent", times );
		return time.regTimeEvent3( times );
	}
	
	@RequestMapping("/regTimeEvent4.ga")
	public ModelAndView regTimeEvent4( String mission, HttpSession session ) throws Exception {
		times = (AdDao) session.getAttribute( "timeEvent" );
		times.setMission( mission );
		session.setAttribute( "timeEvent", times );
		return time.regTimeEvent4( );
	}
	
	@RequestMapping("/timeSelection.ga")
	public ModelAndView timeSelection(String days ) throws Exception {
		return time.timeSelection( days );
	}
	
	@RequestMapping("/selectedTimes.ga")
	public ModelAndView selectedTimes(String days2, String h15, String h18, String h21 ) throws Exception {
		return time.selectedTimes( days2, h15, h18, h21 );
	}
	
	@RequestMapping("/regTimeEventCheck.ga")
	public ModelAndView regTimeEventCheck( HttpSession session ) throws Exception {
		return time.regTimeEventCheck( session );
	}
	
	@RequestMapping("/regTimeEventFinal.ga")
	public ModelAndView regTimeEventFinal( HttpSession session ) throws Exception {
		time.regTimeEventFinal( session );
		return timeEvent();
	}
}
